package top.kaoshanji.p2ch10a;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import top.kaoshanji.p2ch10a.support.MutableObject;

/**
 * 代码清单-p2ch10a-321页a：深拷贝的实现方式的示例
 * author kaoshanji
 * ^_^
 * create time 2025/2/2 20:21
 */
public class MutableObjectCloneGood {

    private static final Logger logger = LogManager.getLogger(MutableObjectCloneGood.class);

    public static void main(String[] args) {

        logger.info("...代码清单-p2ch10a-321页a：深拷贝的实现方式的示例...");

        MutableObjectCloneGood moc = new MutableObjectCloneGood();
        moc.cloneObject();

    }

    public void cloneObject() {
        MutableObject obj = new MutableObject();
        obj.increase();

        MutableObject clonedObj = (MutableObject) obj.clone();
        clonedObj.increase();

        obj.increase();
        System.out.println(clonedObj.getValue());

    }


}
